import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ConfigService } from '@nestjs/config';
import { Logger } from './logger/logger';

async function bootstrap() {
  const app = await NestFactory.create(AppModule
  //   , {
  //   logger: false,
  // }
  );
  const config = app.get(ConfigService);
  app.enableCors();
  // 使用自定义Logger
  app.useLogger(app.get(Logger));
  const prefix = config.get<string>('API_PREFIX');
  app.setGlobalPrefix(prefix);
  // 错误异常捕获 和 过滤处理
  // app.useGlobalFilters(new AllExceptionsFilter());
  // app.useGlobalFilters(new HttpExceptionsFilter());
  await app.listen(config.get<number>('APP_PORT'));
}

bootstrap();
